<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!-- 主体内容 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header"  style="color:#d02e25;font-family: '楷体'; ">
            个人信息
        </div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">我的角色</label>
                <div class="layui-input-inline">
                    <input type="text" name="title" value="${authority}" readonly="readonly" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">账户</label>
                <div class="layui-input-inline">
                    <input type="text" name="title" value="${user.idCard}" readonly="readonly" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">不可更改</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" value="${user.password}" readonly="readonly" required
                           lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux layui-btn" style="background-color: #DDA"
                     onclick="updateOpenPassword();">
                    &nbsp;&nbsp;更&nbsp;&nbsp;改&nbsp;&nbsp;
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="title" value="${user.name}" readonly="readonly" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">不可更改</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <style>
                    .demo--label {
                        margin: 6px 20px 0 0;
                        display: inline-block
                    }

                    .demo--radio {
                        display: none
                    }

                    .demo--radioInput {
                        background-color: #fff;
                        border: 2px solid rgba(0, 0, 0, 0.15);
                        border-radius: 100%;
                        display: inline-block;
                        height: 16px;
                        margin-right: 10px;
                        margin-top: -1px;
                        vertical-align: middle;
                        width: 16px;
                        line-height: 1
                    }

                    .demo--radio:checked + .demo--radioInput:after {
                        background-color: #00A1E9;
                        border-radius: 100%;
                        content: "";
                        display: inline-block;
                        height: 16px;
                        margin-left: 5px;
                        margin-top: 5px;
                        width: 16px
                    }

                    .demo--checkbox.demo--radioInput, .demo--radio:checked + .demo--checkbox.demo--radioInput:after {
                        border-radius: 0
                    }

                    .demo--radio:checked + .demo--radioInput {
                        border: 2px solid #00A1E9;
                    }
                </style>
                <label class="demo--label">
                    <input class="demo--radio" type="radio" name="sex" id="sex0" value="0">
                    <span class="demo--radioInput"></span>先生
                </label>
                <label class="demo--label">
                    <input class="demo--radio" type="radio" name="sex" id="sex1" value="1">
                    <span class="demo--radioInput"></span>女士
                </label>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">简介</label>
                <div class="layui-input-block">
                    <textarea name="desc" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" onclick="submit();">保存</button>
                    <button type="reset" class="layui-btn layui-btn-primary" id="reset">重置</button>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<%--修改密码--%>
<div class="layui-hide" id="show-detail">
    <div class="layui-row layui-card-body">
        <div class="layui-form" lay-filter="">
            <div class="layui-form-item">
                <label class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="oldPassword" lay-verify="required" lay-vertype="tips"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" lay-verify="pass" lay-vertype="tips" autocomplete="off"
                           id="LAY_password" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="repassword" lay-verify="repass" lay-vertype="tips" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="setmypass">确认修改</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("#reset").click();
        var gender = ${user.gender};
        if (gender == 0) {
            var genderInput = $("#sex0");
            genderInput.attr("checked", "checked");
        } else {
            var genderInput = $("#sex1");
            genderInput.attr("checked", "checked");
        }
    });

    function submit() {
        var sex = $("input[name=sex]").val();
        var desc = $("input[name=desc]").val();
        $.post("/ajax/fore/updateuser", {sex: sex, desc: desc}, function (result) {
            layui.use(['form'], function () {
                layer.msg(result.result);
            });
        });
    }

    function updateOpenPassword() {
        refresh("/fore/updatepassword");
    }
</script>
